TextCt Commands TextCt commands are executed via the Dyna dispatching procedure found in the file "FaceProcXY" (or in some other form compatible with your programming environment): Dyna(theCtl,command,a,b,c,d); {Pascal} Dyna(theCtl,command,a,b,c,d); /* C */ call Dyna(theCtl,command,a,b,c,d) !Fortran where "theCtl" is the ControlHandle of a TextCt control (obtained in cControl after calling GetCtl to get control info), and the "command" parameter is one of the integer constants from the include file "TxtCtlStorXY". WARNING: If you save the ControlHandle, it will become invalid if the control is disposed of or reformed by hitting "Apply" or "OK" in ViewIt's Bounds or Control dialogs. Several other points apply to the operation of all or most TextCt commands: • If an error occurs during execution of a TextCt command, then the fRec variable uResult is set equal to a value less than zero. Unless otherwise specified below, this value will be equal to the negative index of the corresponding error string from STR# 1551. • When uRect is used to define a text selection for use with or returned by a TextCt command, its elements refer to 0-based line and column numbers: top = line number of selection start, left = column number of selection start, bottom = line number of selection end, and right = column number of selection end. • When parameter d is used to define the autoscrolling mode (the manner in which the current selection should be scrolled into view), four options are currently supported: -2 = no autoscrolling and no vertical bar update, -1 = no autoscrolling but update vertical scroll bar, 0 = autoscroll to center of window, and +n = autoscroll into view at n lines from bottom of window (where 1 = at bottom). Each TextCt command name, its equivalent number, the parameters and record elements used by the command, and a complete description of the command are presented here. Name Number Parameters & Variables used OpnCTxt 1551 a,b,uName Opens the file named uName into the editor, according to the parameters a and b, where, a = directory specifier (current directory is preserved) 0 = current directory 1 = System folder other = a working directory reference number b = file-opening mode 0 or 1 = use file contents to replace all of existing text 2 = use file contents to replace existing selection 3 = append file contents to existing text The working directory reference number of the opened file is saved in tcVRef, and its file name in the control's title. Passing an empty string in uName can be used to break the connection between an editor and a disk file without affecting the current text in the editor. SavCTxt 1552 a,b,c,d,uName Saves the text in the editor to a file whose name is equal to uName, according to parameters a, b, c, and d, where, a = directory specifier (current directory is preserved) 0 = current directory 1 = System folder other = a working directory reference number b = file-saving mode 0 = save all of text 1 = save selected text only c = file type (0 = "TEXT") d = file creator (0 = application creator = fCreator) The working directory reference number of the saved file is saved in tcVRef, and its file name in the control's title. As with OpnCTxt, passing an empty string in uName can be used to break the connection between an editor and a disk file without affecting the current text in the editor. The optional file and creator types must be in the form of 4-byte integers, but most languages support assigning 4-character strings to long integers. For example, to pass the file type "MYTP", use 'MYTP' with C, longint('MYTP') with Pascal, or assign 'MYTP' to an integer*4 in Fortran and pass this integer to SavCTxt. GetCTxt 1555 uI2,uI4,uRect,uResult,uMenu… Closes any gaps in the existing text block and returns info about the block where, uResult = handle to unlocked text block in memory (handle size ≥ # of char.s) CAUTION: This handle refers to the actual text in the editor, not a copy. Characters in the block can be replaced, but do not attempt to change the size of the block without using a TextCt command to do so. uI2 = # of lines = # of carriage returns + 1 (max uI2 returned = 30,000 lines) uI4 = # of characters uMenuID = selection start (0-based character number) uMenuItem = selection end uRect = text selection bounds SelCTxt 1556 a,b,c,d,uRect,uResult Changes the current text selection to that specified by the parameters a, b, and c. Use negative values of a to also delete the newly selected text. a = selection mode 0 = don't change selection (but will autoscroll) ±1 = select all ±2 = use uRect to define the selection ±3 = use line numbers defined by b and c ±4 = use character numbers defined by b and c ±5 = select all of current line b = selection start (0-based line or character number) c = selection end d = autoscroll mode uResult = number of resulting characters selected or -1 if the selection range did not change In addition, when using a = ±4, negative values of b and c can be used to designate the following character positions: -1 = current selection start -2 = current selection end -3 = beginning of current line -4 = end of current line -5 = beginning of previous line -6 = end of previous line -7 = beginning of next line -8 = end of next line PrnCTxt 1564 a,uResult Prints the currently selected text where a = 0 designates that the standard printing dialogs should first be displayed, and a = -1 prints the selection without displaying the dialogs. If making successive calls to PrnCTxt for the same editor, always use a = 0 at least once to ensure valid printing parameters for that editor. When displaying dialogs, control returns with uResult set equal to -1 if the user presses "Cancel" to cancel one of the dialogs. LineCIO 1565 a,b,d,uString,uResult Moves one line of text to or from an editor via uString, according to a and b where (CR = carriage return), a = line I/O mode -3 = read text to left of insertion bar -2 = read text to left of insertion bar and insert new CR -1 = read line from selected text (up to 255 char.s) 0 = no I/O (but will autoscroll) +1 = insert line into editor (uString is preserved) +2 = insert line into editor and add a carriage return b = ASCII value of optional break character to use when I/O mode = a < -1 (e.g., if b = 9 = TAB, then only char.s back to previous TAB are returned) d = autoscroll mode uResult = # of bytes transferred = length of uString or -1 if a = -1 and no text was selected BlokCIO 1566 a,b,c,d,uResult Moves a block of text to or from an editor where, a = block I/O mode -1 = read and deselect c bytes from selected text 0 = no I/O (but will autoscroll) +1 = insert c bytes at beginning of selected text +2 = insert c bytes after deleting selected text b = address to read from or write to (must not be within an unlocked block) c = # of bytes (characters) to read or write d = autoscroll mode uResult = number of bytes transferred ≤ c SvStCTxt 1569 [none] Saves current editor settings to the TREC resource on disk that is linked to the TextCt control. Equivalent to choosing "Save" in the Editor Setup dialog.